#ifndef OBJECTRENDERWIDGET_H
#define OBJECTRENDERWIDGET_H

#include <QWidget>
#include <QLabel>
#include "QNinePatch.h"

#define DEFAULT_BG_01 ":/img/bg_01.9.png"
#define DEFAULT_BG_02 ":/img/bg_02.9.png"
#define DEFAULT_BG_03 ":/img/bg_03.9.png"
#define DEFAULT_BG_04 ":/img/bg_04.9.png"
#define DEFAULT_BG_05 ":/img/bg_05.9.png"
#define DEFAULT_BG_06 ":/img/bg_06.9.png"
#define DEFAULT_BG_07 ":/img/bg_07.9.png"
#define DEFAULT_BG_08 ":/img/bg_08.9.png"
#define DEFAULT_BG_09 ":/img/bg_09.9.png"

#define DEFAULT_IC_01 ":/img/icon_01.png"
#define DEFAULT_IC_02 ":/img/icon_02.png"
#define DEFAULT_IC_03 ":/img/icon_03.png"
#define DEFAULT_IC_04 ":/img/icon_04.png"
#define DEFAULT_IC_05 ":/img/icon_05.png"
#define DEFAULT_IC_06 ":/img/icon_06.png"
#define DEFAULT_IC_07 ":/img/icon_07.png"

class Object {
public:
    Object() : bgColor(0), bgImage(0), bgIndex(0){ mSize = QSize(0,0); }
    ~Object(){ if(bgImage) delete bgImage; }
    void clear(){
        if(bgImage) { delete bgImage; bgImage = 0; }
        bgColor = 0;
        bgIndex = 0;
        mSize = QSize(0,0);
    }

    QSize mSize;
    QRgb bgColor;
    QNinePatch* bgImage;
    int bgIndex;
};

class ObjectRenderWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ObjectRenderWidget(QWidget *parent = 0);
    ~ObjectRenderWidget();
    void clearData();
    bool setData(QByteArray);
    
protected:
    void paintEvent(QPaintEvent *);

private:
    QList<QLabel*> mChilds;
    QList<QNinePatch*> mBackgrounds;
    QList<QPixmap*> mIcons;
    Object* mObject;
};

#endif // OBJECTRENDERWIDGET_H
